import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Properties;


public class TestProperties {
	public static void main(String[] args) throws FileNotFoundException, IOException {
		Properties p = new Properties();
		
		p.load(new FileReader(new File("res/prop.txt")));  //从文件中读取配置

		
		//-- 显示所有配置
		System.out.println(p.get("1"));
		System.out.println(p.get("2"));
		System.out.println(p.get("3"));
		System.out.println(p.get("4"));
		System.out.println(p.get("5"));

		
		p.put("1", "幻世录");//修改某项配置
		
		Object value = p.get("2");
		p.put("2", new Integer(value + "") + 1);//修改某项配置
		
		p.list(new PrintWriter(new File("res/prop.txt")));	//将配置内的新内容, 重写回文件中
	}
}
